<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/common/base.jsp"%>
<%
	//所在乡镇行政区域编码
	String town = (String) session.getAttribute("agencode");
	ChronicDao chroicdisDao = new ChronicDao();
	List<Chronicdis> chronoicdisList = chroicdisDao.familyChronicdisList();
%>

<%
	String pageNo = request.getParameter("pageNo");
	String mhcx = request.getParameter("mhcx");
	int p = pageNo == null ? 1 : Integer.parseInt(pageNo);
	MemberDao dao = new MemberDao();
	String sql = "select * from t_member where 1=1 ";
	if (mhcx != null && !mhcx.equals("")) {
		sql += " and idcard = '" + mhcx + "'";
	}
	Object[] params = {};
	Page pageBean = dao.queryOjectsByPage(sql, params, p, Constant.ROW);
%>
<%
	for (int i = 0; i < pageBean.getDatas().size(); i++) {
		Member model = (Member) pageBean.getDatas().get(i);
%>

<!DOCTYPE html>
<html lang="zh-cn">
<head>
<base href="<%=basePath%>">

<title>家庭档案列表</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<link rel="stylesheet" href="css/styles.css">
<link rel="stylesheet" href="css/admin.css">
<script src="js/jquery-1.4.4.min.js"></script>
<script src="js/admin.js"></script>
</head>
<body>
	<form method="post" action="" id="listform">
		<div class="panel admin-panel">
			<div class="panel-head">
				<strong class="icon-reorder">参合人员档案信息列表</strong>
			</div>
			<div class="padding border-bottom">
				<ul class="search" style="padding-left: 10px;">

					<li><span>已报销:<span style="color: red;" id="yi"></span>元
					</span></li>
					<li><span>可报销:<span style="color: red;" id="ke"></span>元
					</span></li>
					<li><span>最大报销金额:<span style="color: red;" id="zui"></span>元
					</span></li>
				</ul>
			</div>
			<table class="table table-hover text-center">
				<tr>
					<th width="50">序号</th>
					<th width="50" style="text-align: center;">&nbsp;</th>
					<th>农合证号</th>
					<th>医疗证号</th>
					<th>家庭编号</th>
					<th>与户主关系</th>
					<th>户内编号</th>
					<th>身份证号</th>
					<th>性别</th>
					<th>出生日期</th>
					<th>民族</th>
					<th>健康状况</th>
					<th>文化程度</th>
					<th>是否农村户口</th>
					<th>工作地址</th>
					<th>电话</th>
					<th>年龄</th>
					<th>职业</th>
					<th>姓名</th>



				</tr>

				<tr>
					<td><%=(i + 1)%></td>
					<td><input type="checkbox" name="ids"
						value="<%=model.getFamilycode()%>" /></td>
					<td align="center"><%=model.getNhzcode()%></td>
					<td align="center"><%=model.getYlzcode()%></td>
					<td align="center"><%=model.getFamilycode()%></td>
					<td align="center"><%=model.getHousecode()%></td>
					<td align="center"><%=model.getIdcard()%></td>
					<td><%=model.getSex()%></td>
					<td><%=model.getBirthday()%></td>
					<td><%=model.getNation()%></td>
					<td><%=model.getHealth()%></td>
					<td><%=model.getCulture()%></td>
					<td><%=model.getRelation()%></td>
					<td align="center"><%="1".equals(model.getFarmer())?"是":"否"%></td>
					<td><%=model.getWork()%></td>
					<td><%=model.getPhone()%></td>
					<td><%=model.getAge()%></td>
					<td><%=model.getOccupation()%></td>
					<td><%=model.getName()%></td>

				</tr>

			</table>


		</div>
	</form>



	<div class="panel admin-panel">
		<div class="panel-head" id="add">
			<strong><span class="icon-pencil-square-o"></span>添加慢性病报销</strong>
		</div>
		<div class="body-content">
			<form id="form-add" method="post" class="form-x"
				action="<%=path%>/system/ChronicdisApplyServlet?m=add">

				<div class="form-group">
					<div class="label">
						<label>姓名：</label>
					</div>
					<div class="field">
						<input type="text" class="input w50" value="<%=model.getName()%>"
							name="name" data-validate="required:请输入姓名称" />
						<div class="tips"></div>
					</div>
				</div>

				<div class="form-group">
					<div class="label">
						<label>身份证：</label>
					</div>
					<div class="field">
						<input type="text" id="idcard" class="input w50"
							value="<%=model.getIdcard()%>" name="idcard"
							data-validate="required:请输入身份证" />
						<div class="tips"></div>
					</div>
				</div>

				<div class="form-group">
					<div class="label">
						<label>疾病名称：</label>
					</div>
					<div class="field">
						<select id="chronicname" name="chronicname" class="input w50">

							<%
							for(Chronicdis c : chronoicdisList){
						 %>
							<option value="<%= c.getChronicname()%>">

								<%=c.getChronicname() %>

								<%} %>
							
						</select>

						<div class="tips"></div>
					</div>
				</div>

				<div class="form-group">
					<div class="label">
						<label>报销金额：</label>
					</div>
					<div class="field">
						<input type="text" id="needapply" class="input w50" value=""
							name="applyAccounts" data-validate="required:请输入报销金额" />
						<div class="tips"></div>
					</div>
				</div>

				<div class="form-group">
					<div class="label">
						<label>可报销：</label>
					</div>
					<div class="field">
						<input type="text" id="applyAcount" class="input w50" value=""
							name="applyAcount" data-validate="required:请输入报销金额"
							readonly="readonly" />
						<div class="tips"></div>
					</div>
				</div>

				<div class="form-button">
					<input class="button  bg-blue " style="width: 90px;" type="submit"
						value="提交"> </input>
					<button class="button bg-yellow" id="button" style="width: 90px;"
						type="button">返回</button>
				</div>
			</form>
		</div>
	</div>

	<%
		}
	%>
</body>
<script>
    function changesearch(){
    	window.location.href="<%=path%>/system/PayRecordServlet?m=list&mhcx="+$('.input').val();
    }

    $("#needapply").bind('blur',function(){
  	$.ajax({
    		type:"post",
    		dataType:"json",
    		url:"<%=path%>/system/ChronicdisApplyServlet?m=check&mhcx="+$('#needapply').val()+"&idcard="+$('#idcard').val(),
    		success:function(data){
    			console.log(data);
    			if(data.state==1){
    				$("#applyAcount").val(data.canApply);
    			}else if(data.state==0){
    				alert("您报销的金额已超出");
    				$("span").show();
    				$("#applyAccount").val("");
    				$("#yi").html(data.yiApply);
    				$("#ke").html(data.canApply);
    				$("#zui").html(data.applyMoney);
    			}else{
    				alert("你本年度报销费用已用完");
    			}
    		}
    	});
    });
    
    $(function(){
    	$("span").hide();
    });
    
    $("#button").click(function(){
    	window.location.href="<%=path %>/system/MemberServlet?m=choice";
    });
    
    
</script>
</html>
